package 笔试.涂鸦;

/**
 * @author:谢君臣
 * @Date:2021/9/26-22:50
 * @version:1.0
 * @function:
 */
public class Main {
    public static void main(String[] args) {
        System.out.println(secondHighest("dfa12321afd"));
    }
    public int compareVersion(String version1, String version2) {
        // write code here
        String[] str1 = version1.split("\\.");
        String[] str2 = version2.split("\\.");
        int n = str1.length, m = str2.length;
        int i = 0, j = 0;
        while (i < n || j < m) {
            int a = 0, b = 0;
            if (i < n) a = Integer.parseInt(str1[i++]);
            if (j < m) b = Integer.parseInt(str2[j++]);
            if (a != b)
                return a > b ? 1 : -1;
        }
        return 0;
    }
    public static int secondHighest (String s) {
        // write code here
        int a = -1, b = -1;
        for (char c : s.toCharArray()) {
            if (Character.isDigit(c)) {
                int num = c -'0';
                if (a==-1) {
                    a = num;
                }else if(num>a) {
                    b = a;
                    a = num;
                }else  if (num< a&&num>b){
                    b = num;
                }
            }
        }
        return b;
    }
}
